package util;

import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

public class BeanFactory {
	private static ApplicationContext beanFactory;
	
	private static void loadContext() {
		beanFactory=new ClassPathXmlApplicationContext("/kude-*.xml");
	}
	
	public static <T> T getBean(String beanName) {
		if(beanFactory==null || beanFactory.getBean(beanName) == null) {
			loadContext();
		}
		return (T) beanFactory.getBean(beanName);
	}
}
